package lesson02;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @Author 比特就业课
 * @Date 2023-02-12
 */
public class Demo06_PrintWriter {
    public static void main(String[] args) throws IOException {
        // 创建一个输出流
        FileOutputStream outputStream = new FileOutputStream("d:/temp/test/abc.txt");
        // 根据输出流, 创建一个PrintWriter
        PrintWriter writer = new PrintWriter(outputStream);
        // 写数据
        writer.println("你好世界!!!");
        writer.println("hello world!!!");
        writer.println("这是用PrintWriter写入的内容!!!");
        writer.printf("%s:%d", "单价", 5);
        // 强制刷新缓冲区
        writer.flush();
        // 关闭资源
        writer.close();
        outputStream.close();


    }
}
